<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <!-- <button @click="showStore">仓库内容</button> -->
        <h1></h1>
        <button @click="box">点击了{{this.$store.state.counter}}次</button>
    </div>
</body>
<script src="./node_modules/vue/dist/vue.js"></script>
<script src="../vue-demos/node_modules/vuex/dist/vuex.js"></script>
<script src="../vue-demos/node_modules/axios/dist/axios.js"></script>
<script>
    let INCREMENT="increment";
    let store = new Vuex.Store({
        state:{
            counter:0
        },
        mutations:{
            [INCREMENT]:function(state,{payload}){
                state.counter+=payload.count;
            }
        },
    })
    let vm = new Vue({
        store,
        el:"#app",
        methods:{
            box:function(){
                this.$store.commit({
                    type:INCREMENT,
                    payload:{
                        count:10
                    }
                })
            }
        }
    })
</script>

</html>